package shujia;

import java.sql.*;

public class Demo7PhoenixJDBC {
    public static void main(String[] args) throws SQLException {

        // 1、创建连接
        Connection conn = DriverManager.getConnection("jdbc:phoenix:master,node1,node2:2181");

        // 2、创建statement
        PreparedStatement pStat = conn.prepareStatement("select /*+ INDEX(DIANXIN DIANXIN_INDEX_COVER) */ * from dianxin where x=? and y =?");

        // 3、配置参数
        pStat.setDouble(1,117.233);
        pStat.setDouble(2,31.833);

        // 4、执行SQL
        ResultSet rs = pStat.executeQuery();

        // 5、获取数据
        while(rs.next()){
            String mdn = rs.getString("mdn");
            String start_date = rs.getString("start_date");
            String end_date = rs.getString("end_date");
            String county = rs.getString("county");

            System.out.println(mdn+","+start_date+","+end_date+","+county);
        }

        // 关闭连接
        pStat.close();
        conn.close();

    }
}
